1. Field of the Invention
The present invention relates to the design of programming languages for computer systems and associated development tools. More specifically, the present invention relates to a method and an apparatus for associating metadata attributes that do not affect program execution with program elements.
2. Related Art
It is often desirable for programmers to annotate program elements, such as fields, methods, and classes, as having particular attributes that indicate that they should be processed in special ways by development tools, deployment tools, or run-time libraries. We call such annotations “metadata.” Ideally, this metadata should be easily accessible at development time, deployment time, and run time.
Metadata has many uses. Custom tools may use metadata to generate auxiliary source files to be used in conjunction with the source file containing the annotation. For example, a stub generator can generate remote procedure call stubs based on annotations indicating that certain methods are designed for remote use.
A number of existing mechanisms presently allow programmers to associate metadata with programs. For example, the C++ programming language has a preprocessor directive called “#pragma” that affects the actions of the compiler as it compiles the program. Some uses of this directive associate metadata with the program. For example, this directive's COPYRIGHT function associates a copyright string with a program. The copyright string is then embedded in the object code where it can be read with the Unix strings utility. However, the C++ #pragma directive does not allow the programmer to associate arbitrary metadata, does not allow metadata to be associated with particular program elements, and does not allow metadata to be read at run time.
JAVA's doclet API has been used to associate metadata with program elements by various tools such as ejbdoclet, webdoclet, ejbgen, and icontract. Although this usage does allow the programmer to associate arbitrary metadata with particular program elements, it does not allow metadata to be read at run time, nor does it provide a mechanism to manage the namespace of metadata attributes.
Hence, what is needed is a facility that allows programmers to associate arbitrary metadata with arbitrary program elements in a manner that allows the metadata to be accessed by development tools, deployment tools, and programmatically at runtime without the limitations of the mechanisms described above.